package com.example.hotelmanagement.mapper;

import com.example.hotelmanagement.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    // 插入新用户
    @Insert("INSERT INTO users (username, password, email) VALUES (#{username}, #{password}, #{email})")
    int insertUser(User user);

    // 根据用户名查找用户
    @Select("SELECT * FROM users WHERE username = #{username}")
    User findByUsername(String username);

    // 根据ID查找用户
    @Select("SELECT * FROM users WHERE id = #{id}")
    User findById(Long id);

    // 更新用户信息
    @Update("UPDATE users SET username = #{username}, password = #{password}, email = #{email} WHERE id = #{id}")
    int updateUser(User user);

    // 删除用户
    @Delete("DELETE FROM users WHERE id = #{id}")
    int deleteUser(Long id);
}
